var WxAutoImage = require('../../../utils/detailImage');
var app = getApp();

Page({
    data: {
        imgUrls: [""],
        imgData:'',
        ite:'',
        indicatorDots: true,
        vertical: false,
        autoplay: true,
        interval: 3000,
        duration: 1200,
        iscollect: true
    },
    onLoad(){
      
   
     
    },
    addcart(e){
       
        wx.request({
          url: app.globalData.api+'insertCart?openid='+wx.getStorageSync('openid')+"&goodid="+e.currentTarget.dataset.id+'&sum=1',
          success(){
            wx.showModal({
                title: '添加成功',
                content:'点击确认前往购物车',
             success(res){
                 if(res.confirm){
                 wx.navigateTo({
                   url: '../cart/cart',
                 })
                }
             }
               
              })
          }
        })
    },
    onShow(){
        let that=this;
        const eventChannel = this.getOpenerEventChannel();
        eventChannel.on('data1',function(ret){
            console.log(ret)
            if(ret.img!=null){
            ret.img=  ret.img.split(",")
          
            }
            that.setData({
                ite:ret
            })
        })
    
   
    },

    cusImageLoad: function(e){
        var that = this;
        that.setData(WxAutoImage.wxAutoImageCal(e));
    }
})